package com.ldl.service.impl;

import java.sql.SQLException;

import com.ldl.dao.CountDao;
import com.ldl.dao.impl.CountDaoImpl;
import com.ldl.entity.Count;
import com.ldl.service.CountService;

/**
 * @author Administrator
 * Author : L.D.L
 * E-mail : 1419485293@qq.com
 * Date : 2020年8月7日下午5:04:36
 */
public class CountServiceImpl implements CountService{

	private CountDao countDao = new CountDaoImpl();
	@Override
	public int getCount() {
		try {
			Count count = countDao.select();
			return Integer.valueOf(count.getCount());
		}catch (Exception e) {
			return 0;
		}
	}

	@Override
	public void saveCount(int count) {
		Count Count = null;
		try {
			Count = countDao.select();
			Count.setCount(count);
			countDao.update(count);
		}catch (Exception e) {
			Count = new Count();
			Count.setCount(count);
			try {
				countDao.insert(Count);
			} catch (SQLException e1) {
				
			}
		}
	}

}
